package com.matrix.marketing.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.api.marketing.vo.UserCouponVO;
import com.matrix.marketing.entity.UserCoupon;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author 有点甜
 * @since 2025/8/1
 */
@Mapper
public interface UserCouponMapper extends BaseMapper<UserCoupon> {
    List<UserCouponVO> findAvailableCoupons(@Param("userId") Long userId,
                                            @Param("shopId") Long shopId,
                                            @Param("now") LocalDateTime now);

    @MapKey("issuerType")
    List<Map<String, Object>> sumTotalSavingsByIssuer();

    UserCoupon selectByIdForUpdate(@Param("id") Long id);

}
